<!DOCTYPE html>
<html lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>注册</title>

<!-- 引入css -->
  {include file="Common/css"}
<!-- 引入css -->

  </head>

  <body class="login">
    <div>
      <a class="hiddenanchor" id="signup"></a>
      <a class="hiddenanchor" id="signin"></a>

      <div class="login_wrapper">
        <div class="animate form login_form">
          <section class="login_content">

            <form action="{:url('login/registered_add')}" method="post">

              <h1>Registered Form</h1>
              
              <div>
                <input type="text" class="form-control" placeholder="username" name="username" maxlength="8" required="" onkeypress="return /[\w\u4e00-\u9fa5]/.test(String.fromCharCode(window.event.keyCode))" onpaste="return !/[^\w\u4e00-\u9fa5]/g.test(window.clipboardData.getData('Text'))" ondragenter="return false" autocomplete="off" onpaste="return false" oncontextmenu="return false">
              </div>

              <div>
                <input type="password" class="form-control" placeholder="Password" name="password" maxlength="16" required="" onkeyup="value=value.replace(/[\W]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" autocomplete="off" onpaste="return false" oncontextmenu="return false">
              </div>

              <div>
                <input type="email" class="form-control" placeholder="Email" name="usernmae_email" maxlength="20" required="" autocomplete="off" onpaste="return false" oncontextmenu="return false">
              </div>

              <div>
                <input type="text" class="form-control" placeholder="tel" id="tel" value="18937115666" name="tel" maxlength="11" required="" autocomplete="off" onpaste="return false" oncontextmenu="return false">
                <div class="yan">
                  <input type="button" id="btn" class="btn_mfyzm " value="获取手机验证码" />
                </div>
              </div>
              
              <div class="yzm">
                <input type="text" class="form-control" placeholder="验证码" name="verifyCode" maxlength="5" required="" autocomplete="off" onkeyup="value=value.replace(/[^\a-\z\A-\Z0-9]/g,'')">
                <div>{:captcha_img()}</div>
              </div>
              <br />
              <div>
              <input type="submit" class="btn btn-default submit" value="reg in">
                <a class="reset_pass" href="#">Lost your password?</a>
              </div>

              <div class="clearfix"></div>

              <div class="separator">
                <p class="change_link">
                  <a href="{:url('login/login')}" class="to_register"> Create Account </a>
                </p>

                <div class="clearfix"></div>
                <br />

                <div>
                  <h1><i class="fa fa-paw"></i> 管理系统!</h1>
                  <p>©2018 All Rights Reserved.</p>
                </div>
              </div>

            </form>
          </section>
        </div>
      </div>
    </div>
  </body>
</html>

<script src="__STATIC__/js/jquery.js"></script>
<script>
  var InterValObj; //timer变量，控制时间 
  var count = 60; //间隔函数，1秒执行
  var curCount;//当前剩余秒数 
  $(".btn_mfyzm").click(function()
  {
    var obj=$(this);
    var tel = $("#tel").serialize();
      $.ajax(
      {    
          type:"get",    
          url:"{:url('login/yzm')}",    
          data:tel,
          success:function(data){  
            if(data==1){
                curCount = count;
                obj.attr("disabled", "true");
                obj.removeClass("btn-info");
                obj.val(curCount + "秒后重发");
                InterValObj = window.setInterval(SetRemainTime, 1000); 
            }else{
                alert(' ✖ 验证码发送失败，请重新发送');
            }
          }    
      });
  });

  //计时器
  function SetRemainTime() 
  { 
    if (curCount == 0) {         
        window.clearInterval(InterValObj);//停止计时器 
        $(".btn_mfyzm").removeAttr("disabled");//启用按钮 
        $(".btn_mfyzm").removeClass('white').addClass('blue');
        $(".btn_mfyzm").val("发送验证码");
    }else{
        curCount--; 
        $(".btn_mfyzm").val(curCount + "秒后重发"); 
    }   
  }

</script>
